/*
 * @Author: luochun 
 * @Date: 2024-07-07 11:25:51 
 * @Last Modified by: luochun
 * @Last Modified time: 2024-07-07 17:57:46
 * 实现乘法表
 * 
 * 实现乘法口诀表还是用字符串拼接
 * 在实现循环的时候要想清楚循环的退出条件
 */

let str = ''
for (let i = 1; i < 10; i++) {
    for(let j = 1; j <= i; j++) {
        str += `${j} * ${i} = ${i * j}` + '\t'
        if (i === j) {
            str += '\n'
        }
    }
}

console.log(str);

let mutiple = ''
// 倒序乘法口诀表
for (let i = 9; i>0; i--) {
    for(let j = 1; j <= i; j++) {
        mutiple += `${i} * ${j} = ${i * j}` + '\t'
        if (i === j) {
            mutiple += '\n'
        }
    }  
}

console.log(mutiple);

const arr = new Array(4, 2)
console.log('🚀 ~ This is a result of console.log ~ ✨: ', arr.length);

arr[7] = 'fah a' // 中间会用 empty 补齐
console.log('🚀 ~ This is a result of console.log ~ ✨: ', arr, arr.length);

const arr1 = [1, 2, 3, 4, 5]

// 反转数组
function reverse(arr) {
    const temp = []
    for (let i = arr.length - 1; i >= 0; i--) {
        temp[temp.length] = arr[i]
    }
    return temp
}

console.log(reverse(arr1));

console.log('🚀 ~ This is a result of console.log ~ ✨: ', arr1.toString()); // 1,2,3,4,5
console.log('🚀 ~ This is a result of console.log ~ ✨: ', arr1.indexOf(3));
console.log('🚀 ~ This is a result of console.log ~ ✨: ', arr1.join(''), typeof arr1);

const str1 = 'jjafjaj'
console.log('🚀 ~ This is a result of console.log ~ ✨: ', str1.split('a'));

const set = new Set([1,2,3,5,5,5,2]);

console.log('🚀 ~ This is a result of console.log ~ ✨: ', set, typeof set);
